/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pstreets.practices.demo;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.google.inject.Inject;
import com.mapdigit.practices.compositeui.eventbroker.CancelEventArgs;
import com.mapdigit.practices.compositeui.eventbroker.CancelEventHandler;
import com.mapdigit.practices.compositeui.eventbroker.EventArgs;
import com.mapdigit.practices.compositeui.eventbroker.EventHandler;
import com.mapdigit.practices.compositeui.winforms.Form;
import com.mapdigit.practices.compositeui.winforms.UIElement;

import roboguice.util.Ln;

/**
 *
 * @author james
 */
public class DemoView extends Form implements IDemoView,
        EventHandler,CancelEventHandler {

    @UIElement (R.id.button) Button button;
    @UIElement (R.id.button1) Button button1;
    
    @Inject DemoViewPresenter presenter;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.workitem);
    	 button.setOnClickListener(mGoListener);
         button1.setOnClickListener(mGoListener1);
        
    }
    
    @Override
    protected void initPresenter(){
        presenter.View=this;
        presenter.onViewStarted();
    }
    
 private OnClickListener mGoListener = new OnClickListener()
    {
        public void onClick(View v)
        {
           presenter.handleOnClick();
        }


    };
 
 private OnClickListener mGoListener1 = new OnClickListener()
    {
        public void onClick(View v)
        {
        
                
        }


    };

    public void handleEvent(Object sender, EventArgs event) {
        Ln.d(sender, "event");
    }

    public void handleEvent(Object sender, CancelEventArgs event) {
        Ln.d(sender, "CancelEventArgs");
    }

    public void setTitle(String title) {
        Toast.makeText(this, "set title", 
    			Toast.LENGTH_LONG).show();
    }
    
    
    
}
